package com.itheima.web.converter;

import org.springframework.core.convert.converter.Converter;
import org.springframework.util.StringUtils;

import java.text.SimpleDateFormat;
import java.util.Date;

public class StringToDateConverter implements Converter<String, Date> {
    @Override
    public Date convert(String s) {
        Date date = null;
        if(!StringUtils.isEmpty(s)){
            try {
                date = new SimpleDateFormat("yyyy-MM-dd").parse(s);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return date;
    }
}
